<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>


















    </style>
</head>
<body>
    <div class="box">
        <span>的风格和健康体育</span>
    </div>

    <input type="text">
    <script>
        //获取inpu
        let input = document.querySelector('input')
        //获取div
        let div = document.querySelector('div')

        //1.将输入框的内容插入到div中
        input.onkeyup = function(e){
            //不是回车不执行
            if (e.keyCode!=13)return 
            //获取值
            let val = input.value
            let span = document.createElement('span')
            span.innerHTML= val
            //获取span宽度
            let sapnwidth = sapn.offsetWidth

            let leftint = setInterval(o=>{
                if (left<=-sapnwidth-10) {
                    clearInterval(leftint)
                    span.remove()                   
                }
                left--
                span.style.left = left+'px'
            },10)
            input.value = ''
            }   
            function settop() {
                return Math.floor(Math.random()*300)
            }
            function setcolor() {
                return Math.floor(Math.random()*256)
            }
        
    </script>
</body>
</html>